package aimozg.joglfw.figures;

import aimozg.joglfw.GLColor;

/**
* Created by IntelliJ IDEA.
* User: aimozg
* Date: 06.01.11
* Time: 14:12
*/
public class ColorRef {
	public final GLColor defaultColor;
	public final String name;

	public GLColor get() {
		return defaultColor;
	}

	public GLColor get(Palette palette) {
		if (name == null) return defaultColor;
		GLColor color = palette.get(name);
		return (color == null) ? defaultColor : color;
	}

	public ColorRef(GLColor color) {
		this.defaultColor = color;
		this.name = null;
	}

	public ColorRef(String name) {
		this.defaultColor = GLColor.TRANSPARENT;
		this.name = name;
	}

	public ColorRef(GLColor defaultColor, String name) {
		this.defaultColor = defaultColor;
		this.name = name;
	}
}
